package com.bt7274.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bt7274.mapper.CategoryMapper;
import com.bt7274.pojo.Category;
import com.bt7274.service.CategoryService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Data 2025/5/28 11:22
 * @Author hp
 * @Version 1.0
 * @Description CategoryServiceImpl
 */
@Service
public class CategoryServiceImpl implements CategoryService {
    @Resource
    private CategoryMapper categoryMapper;

    @Override
    public List<Category> queryAll() {
        return categoryMapper.selectList(
                new QueryWrapper<Category>().
                        orderByAsc("sort_index")
        );
    }

    @Override
    public Category getCategoryBySlug(String slug) {
        return categoryMapper.selectOne(
                new QueryWrapper<Category>().eq("slug", slug)
        );
    }
}
